# -*- coding: utf-8 -*-
# @Time : 2020/9/24 15:52
# @Author : HEAD
# @Email : scg@gmail.com
# @File : config.py
# @Project : scg_interface
"""
从配置文件中获取各个段信息
"""
import os
import configparser


base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


class Config(object):
    """封装获取conf文件类"""
    def __init__(self, filename="default.conf"):
        self.cf = configparser.ConfigParser()
        self.cf.read(os.path.join(base_path, "datas", filename))

    def get_runtime(self, option):
        return self.cf.get("runtime", option)

    def get_server(self, option):
        return self.cf.get("server", option)

    def get_db_test(self, option):
        return self.cf.get("db_test", option)

    def get_email(self, option):
        return self.cf.get("email", option)


if __name__ == "__main__":
    c = Config()
    print(c.get_server("test"))